package com.ltz.web.well;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ltz.model.ObservationRecord;
import com.ltz.model.Page;
import com.ltz.model.User;
import com.ltz.service.well.ObservationRecordService;

@Controller
@RequestMapping("/obsRecord")
public class ObservationRecordController {
	@Resource
	private ObservationRecordService obsRecordService;

	@ResponseBody
	@RequestMapping("loadList")
	public Page loadList(Page page,String queryStr){
		return obsRecordService.loadList(page,queryStr);
	}
	@RequestMapping(value="doAddRecord",method=RequestMethod.POST)
	public String doAddWell(ObservationRecord w,HttpServletRequest request){
		User user=(User) request.getSession().getAttribute("user");
//		w.setDate(request.getParameter("date"));
		obsRecordService.doAddWell(user, w);
		return "/save_ok";
	}
	@RequestMapping(value="doUpdateRecord",method=RequestMethod.POST)
	public String doUpdateWell(HttpServletRequest request,ObservationRecord w){
		User user=(User) request.getSession().getAttribute("user");
		obsRecordService.doUpdateWell(user,w);
		return "/save_ok";
	}
	@ResponseBody
	@RequestMapping("doDeleteRecord")
	public Boolean doDeleteWellGroup(int recordId){
		return obsRecordService.doDeleteWell(recordId);
	}
	@ResponseBody
	@RequestMapping("getWellList")
	public List getWellList(){
		return obsRecordService.getWellList();
	}
}
